from functools import partial

# 基础用法
def multiply(x, y, z):
    return x * y * z

# 固定第一个参数
double = partial(multiply, 2)
print(double(3, 4))  # 输出: 24

# 固定关键字参数
multiply_by_10 = partial(multiply, z=10)
print(multiply_by_10(2, 3))  # 输出: 60

# 实际应用：创建专用函数
def power(base, exponent):
    return base ** exponent

square = partial(power, exponent=2)
cube = partial(power, exponent=3)

print(square(5))  # 输出: 25
print(cube(3))    # 输出: 27